//
//  SelectCardView.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/28.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "SelectCardView.h"
#import <Masonry.h>
@implementation SelectCardView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupViews];
    }
    return self;
}

-(void)setupViews{
    
    self.topView = [[UIView alloc] init];
    self.topView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(138);
    }];
    
    self.moneyNumLab = [[UILabel alloc] init];
    self.moneyNumLab.text = @"￥8";
    self.moneyNumLab.font = [UIFont systemFontOfSize:24];
    self.moneyNumLab.textColor = [UIColor blackColor];
    [self.topView addSubview:self.moneyNumLab];
    [self.moneyNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.topView);
        make.top.mas_equalTo(20);
    }];
    
    self.receiveMoneyLab = [[UILabel alloc] init];
    self.receiveMoneyLab.text = @"收款金额";
    self.receiveMoneyLab.font = [UIFont systemFontOfSize:14];
    self.receiveMoneyLab.textColor = ETColorWithRGB(153, 153, 153);
    [self.topView addSubview:self.receiveMoneyLab];
    [self.receiveMoneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.topView);
        make.top.equalTo(self.moneyNumLab.mas_bottom).offset(10);
    }];
    
    
    /*
    self.rateLab = [[UILabel alloc] init];
    self.rateLab.text = @"费率:";
    self.rateLab.font = [UIFont systemFontOfSize:13];
    self.rateLab.textColor = ETColorWithRGB(153, 153, 153);
    [self.topView addSubview:self.rateLab];
    [self.rateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.equalTo(self.receiveMoneyLab.mas_bottom).offset(20);
    }];
    
    self.arriveLab = [[UILabel alloc] init];
    self.arriveLab.text = @"秒到时间:";
    self.arriveLab.font = [UIFont systemFontOfSize:13];
    self.arriveLab.textColor = ETColorWithRGB(153, 153, 153);
    [self.topView addSubview:self.arriveLab];
    [self.arriveLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.equalTo(self.rateLab.mas_bottom).offset(20);
    }];
    
    self.supportBankLab = [[UILabel alloc] init];
    self.supportBankLab.text = @"支持银行:";
    self.supportBankLab.font = [UIFont systemFontOfSize:13];
    self.supportBankLab.textColor = ETColorWithRGB(153, 153, 153);
    [self.topView addSubview:self.supportBankLab];
    [self.supportBankLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.equalTo(self.arriveLab.mas_bottom).offset(20);
    }];
    
    
    self.rateValueLab = [[UILabel alloc] init];
    self.rateValueLab.text = @"0.49%+2.0元/笔";
    self.rateValueLab.font = [UIFont systemFontOfSize:13];
    self.rateValueLab.textColor = ETColorWithRGB(255, 139, 66);
    [self.topView addSubview:self.rateValueLab];
    [self.rateValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.rateLab);
    }];
    
    self.arriveValueLab = [[UILabel alloc] init];
    self.arriveValueLab.text = @"每天8:00-22:00";
    self.arriveValueLab.font = [UIFont systemFontOfSize:13];
    self.arriveValueLab.textColor = ETColorWithRGB(51, 51, 51);
    [self.topView addSubview:self.arriveValueLab];
    [self.arriveValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.arriveLab);
    }];
    
    self.supportBankValueLab = [[UILabel alloc] init];
    self.supportBankValueLab.text = @"支持所有常见银行";
    self.supportBankValueLab.font = [UIFont systemFontOfSize:13];
    self.supportBankValueLab.textColor = ETColorWithRGB(51, 51, 51);
    [self.topView addSubview:self.supportBankValueLab];
    [self.supportBankValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.supportBankLab);
    }];
     */
    
    
    
    self.backgroundView = [[UIView alloc] init];
    self.backgroundView.backgroundColor = ETColorWithRGB(242, 244, 246);
    self.backgroundView.layer.cornerRadius = 5;
    [self addSubview:self.backgroundView];
    [self.backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(self.topView.mas_bottom).offset(10);
        make.height.mas_equalTo(277);
    }];
    
    self.midView = [[UIView alloc] init];
    self.midView.backgroundColor = [UIColor whiteColor];
    self.midView.layer.cornerRadius = 5;
    [self.backgroundView addSubview:self.midView];
    [self.midView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(55);
    }];
    
    
    self.headImv = [[UIImageView alloc] init];
    self.headImv.image = [UIImage imageNamed:@"icon_card_head"];
    [self.midView addSubview:self.headImv];
    [self.headImv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.equalTo(self.midView);
        make.width.mas_equalTo(24);
        make.height.mas_equalTo(24);
    }];
    
    self.nameLab = [[UILabel alloc] init];
    self.nameLab.text = @"王小白";
    self.nameLab.textColor = ETColorWithRGB(51, 51, 51);
    self.nameLab.font = [UIFont systemFontOfSize:16];
    [self.midView addSubview:self.nameLab];
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headImv.mas_right).offset(3);
        make.centerY.equalTo(self.midView);
    }];
    
    self.holdCrdLab = [[UILabel alloc] init];
    self.holdCrdLab.text = @"持卡人";
    self.holdCrdLab.textColor = ETColorWithRGB(153, 153, 153);
    self.holdCrdLab.font = [UIFont systemFontOfSize:13];
    [self.midView addSubview:self.holdCrdLab];
    [self.holdCrdLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab.mas_right).offset(5);
        make.centerY.equalTo(self.midView);
    }];
    
    
    self.arrowBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.arrowBtn setImage:[UIImage imageNamed:@"selectCardicon_arrow_right"] forState:(UIControlStateNormal)];
    [self.midView addSubview:self.arrowBtn];
    [self.arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.equalTo(self.midView);
        make.width.mas_equalTo(16);
        make.height.mas_equalTo(16);
    }];
    
    self.selectcardBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.selectcardBtn setTitle:@"选择付款卡" forState:(UIControlStateNormal)];
    [self.selectcardBtn setTitleColor:ETColorWithRGB(91, 113, 255) forState:(UIControlStateNormal)];
    self.selectcardBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.midView addSubview:self.selectcardBtn];
    [self.selectcardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrowBtn.mas_left);;
        make.centerY.equalTo(self.midView);
    }];
    
    
    self.bottomView = [[UIView alloc] init];
    self.bottomView.backgroundColor = [UIColor whiteColor];
    self.bottomView.layer.cornerRadius = 5;
    [self.backgroundView addSubview:self.bottomView];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(-0);
        make.top.equalTo(self.midView.mas_bottom).offset(5);
        make.height.mas_equalTo(222);
    }];
    
    self.tableView = [[UITableView alloc] initWithFrame:self.bottomView.bounds style:(UITableViewStyleGrouped)];
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.layer.cornerRadius = 5;
    [self.bottomView addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomView);
        make.right.equalTo(self.bottomView);
        make.top.equalTo(self.bottomView);
        make.bottom.equalTo(self.bottomView);
    }];
    
    self.rateAndtimeView = [[UIView alloc] init];
    self.rateAndtimeView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.rateAndtimeView];
    [self.rateAndtimeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(self.backgroundView.mas_bottom).offset(10);
        make.height.mas_equalTo(98);
    }];
    
    
    
    self.rateLab = [[UILabel alloc] init];
    self.rateLab.text = @"预估费率:";
    self.rateLab.textAlignment = NSTextAlignmentCenter;
    self.rateLab.font = [UIFont systemFontOfSize:13];
    self.rateLab.textColor = ETColorWithRGB(153, 153, 153);
    [self.rateAndtimeView addSubview:self.rateLab];
    [self.rateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.equalTo(self.rateAndtimeView).offset(20);
    }];
    
    self.arriveLab = [[UILabel alloc] init];
    self.arriveLab.text = @"秒到时间:";
    self.arriveLab.font = [UIFont systemFontOfSize:13];
    self.arriveLab.textColor = ETColorWithRGB(153, 153, 153);
    [self.rateAndtimeView addSubview:self.arriveLab];
    [self.arriveLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.bottom.equalTo(self.rateAndtimeView.mas_bottom).offset(-20);
    }];
    
    
    self.rateValueLab = [[UILabel alloc] init];
//    self.rateValueLab.text = @"0.49%+2.0元/笔";
    self.rateValueLab.font = [UIFont systemFontOfSize:13];
    self.rateValueLab.textColor = ETColorWithRGB(255, 139, 66);
    [self.rateAndtimeView addSubview:self.rateValueLab];
    [self.rateValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.rateLab);
    }];
    
    self.arriveValueLab = [[UILabel alloc] init];
//    self.arriveValueLab.text = @"每天8:00-22:00";
    self.arriveValueLab.font = [UIFont systemFontOfSize:13];
    self.arriveValueLab.textColor = ETColorWithRGB(51, 51, 51);
    [self.rateAndtimeView addSubview:self.arriveValueLab];
    [self.arriveValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.arriveLab);
    }];
    
    
    

    
    
    
    
    
    
}

@end
